package com.itheima.controller;

import com.itheima.pojo.Result;
import com.itheima.service.EmpService;
import com.itheima.service.StudentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@Slf4j
@RestController
@RequestMapping("/report")
public class ReportController {

    @Autowired
    EmpService empService;
    @Autowired
    StudentService studentService;


    /*echarts饼图*/

    //统计员工性别
    @GetMapping("/empGenderData")
    public Result empGenderData() {
        log.info("员工性别统计");
        //使用map：阅读性不好。使用实体类，清晰
        //接口文档[],集合
        List<Map<String, Object>> list = empService.getEmpGenderData();
        //List<Map> list = empService.getEmpGenderData();
        return Result.ok(list);
    }

    //员工职位统计数据
    @GetMapping("/empJobData")
    public Result empJobData() {
        log.info("员工职位统计数据");
        //接口文档{},实体类或者对象（用Map）
        Map<String, List<Object>> map = empService.getEmpJobData();
        //Map<String, List> map = empService.getEmpJobData();
        return Result.ok(map);
    }

    //学员统计
    @GetMapping("/studentData")
    public Result studentDate() {
        log.info("学员人数统计");
        Map<String, List<Object>> map = studentService.getStudentData();
        return Result.ok(map);
    }
}
